package io.mvvm.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @program: Netty
 * @description: 初始化配置
 * @author: 潘
 * @create: 2021-04-24 16:28
 **/
public class NettyHttpServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        /* 向通道加入处理器 */
        // 得到通道
        ChannelPipeline pipeline = ch.pipeline();
        // 加入Http编解码器
        pipeline.addLast(new HttpServerCodec());
        // 加入自定义handler
        pipeline.addLast(new NettyHttpServerHandler());
    }
}
